package org.southyin.controller.cms_category;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.southyin.model.CmsCategory;
import org.southyin.service.CmsCategoryService;
import org.southyin.service.impl.CmsCategoryServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "CmsCategoryListServlet",value = "/category/list")
public class CmsCategoryListServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        CmsCategoryService service = new CmsCategoryServiceImpl();
        List<CmsCategory> list = service.listCmsCategory();
        response.getWriter().println(new ObjectMapper().writeValueAsString(list));
    }
}
